package com.linksoul.utils;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: cc
 * @Date: 2025/05/01/12:10
 **/
public class RequestIdHolder {
    private static final ThreadLocal<String> REQUEST_ID_HOLDER = new ThreadLocal<>();

    /**
     * 设置当前请求的requestId（通常在拦截器中调用）
     */
    public static void set(String requestId) {
        REQUEST_ID_HOLDER.set(requestId);
    }

    /**
     * 获取当前请求的requestId
     */
    public static String get() {
        return REQUEST_ID_HOLDER.get();
    }

    /**
     * 清除ThreadLocal（防止内存泄漏）
     */
    public static void remove() {
        REQUEST_ID_HOLDER.remove();
    }
}